<template>
	<view class="tianjia_ka">
		<view class="list">
			<view class="info_list">
				<view class="info">联系人</view>
				<input class="input" type="text" value="" v-model="name" placeholder="请填写联系人" placeholder-style="color:#a5a5a5;"/>
			</view>
			<view class="info_list">
				<view class="info">手机号</view>
				<input class="input" type="text" value="" v-model="phone" placeholder="请填写手机号" placeholder-style="color:#a5a5a5;"/>
			</view>
			<view class="info_list">
				<view class="info">银行</view>
				<input class="input" type="text" value="" v-model="banktype" placeholder="请填写银行" placeholder-style="color:#a5a5a5;"/>
			</view>
			<view class="info_list">
				<view class="info">开户行</view>
				<input class="input" type="text" value="" v-model="opbank" placeholder="请填写开户行" placeholder-style="color:#a5a5a5;"/>
			</view>
			<view class="info_list">
				<view class="info">卡号</view>
				<input class="input" type="text" value="" v-model="cardnum" placeholder="请填写卡号" placeholder-style="color:#a5a5a5;"/>
			</view>
		</view>
		<view class="qd_btn" @click="sub">保存</view>
	</view>
</template>

<script>
	export default {
		components:{
		},
		data() {
			return {
				name:'',//收货人
				phone:'',//手机号
				cardnum:'',//性别
				banktype:'',//手机号
				opbank:'',//性别
				userinfo:[]
			}
		},
		onLoad() {
			this.userinfo=uni.getStorageSync('user');
			this.getinfo();
		},
		methods: {
			getinfo(){
				var that=this;
				this.$http.get('user/getBankcard',{}).
				then(function (response) {
					var data = response.data;
					if(data.hasData == 1){
						that.opbank = data.opbank;
						that.banktype = data.banktype;
						that.cardnum = data.cardnum;
						that.phone = data.phone;
						that.name = data.name;
					}
				}).catch(function (error) {
					console.log(error);
				});
			},
			sub(){
				if(this.cardnum==''||this.cardnum==undefined||this.cardnum==null){
					uni.showToast({
						icon:'none',
						title:'请填写卡号'
					})
					return;
				}
				if(this.opbank==''||this.opbank==undefined||this.opbank==null){
					uni.showToast({
						icon:'none',
						title:'请填写开户行'
					})
					return;
				}
				
				if(this.banktype==''||this.banktype==undefined||this.banktype==null){
					uni.showToast({
						icon:'none',
						title:'请填写银行'
					})
					return;
				}
				if(this.phone==''||this.phone==undefined||this.phone==null){
					uni.showToast({
						icon:'none',
						title:'请填写手机号'
					})
					return;
				}
				if(this.name==''||this.name==undefined||this.name==null){
					uni.showToast({
						icon:'none',
						title:'请填写姓名'
					})
					return;
				}
				var that=this;
				this.$http.post('user/joinBankcard',{'banktype':that.banktype,'cardnum':that.cardnum,'opbank':that.opbank,'name':that.name,'phone':that.phone}).
				then(function (response) {
					uni.showToast({
						title:"保存成功",
						icon:'none'
					})
					var clock=setInterval(function(){
						clearInterval(clock);
						uni.navigateBack();
					},1500);
				}).catch(function (error) {
					console.log(error);
				});
				
				
			}
		}
	}
</script>

<style scoped lang="scss">
	.tianjia_ka{
		width: 100%;
		.list{
			padding: 0 30rpx;
			.info_list1{
				padding: 30rpx 0;
				display: flex;
				// align-items: center;
				border-bottom:1px solid #e5e5e5;
				.info{
					margin-right: 20rpx;
					text-align-last: justify;
					width: 140rpx;
					color: #3b3b3b;
					font-size: 30rpx;
				}
				.list{
					margin-left: 70rpx;
					.list_con{
						display: flex;
						.info1{
							display: flex;
							align-items: center;
							padding-left: 50rpx;
							.left{
								align-items: center;
								display: flex;
								font-size: 30rpx;
								color: #3b3b3b;
							}
						}
					}
				}
				.input{
					flex: 1;
					font-size: 28rpx;
					color: #a5a5a5;
				}
				.right{
					width: 540rpx;
					color: #a5a5a5;
					font-size: 30rpx;
					display: flex;
					justify-content: space-between;
					align-items: center;
					.r_left{
						.name{
							color: #454545;
						}
						.r_l_img{
							width: 28rpx;
							height: 40rpx;
							margin-right: 10rpx;
						}
					}
					.s_img{
						width: 20rpx;
						height: 30rpx;
					}
				}
			}
			.info_list{
				height: 100rpx;
				display: flex;
				align-items: center;
				border-bottom:1px solid #e5e5e5;
				.info{
					margin-right: 20rpx;
					text-align-last: justify;
					width: 140rpx;
					color: #3b3b3b;
					font-size: 30rpx;
				}
				.list{
					margin-left: 70rpx;
					.list_con{
						display: flex;
						.info1{
							height:100rpx;
							display: flex;
							align-items: center;
							padding-left: 50rpx;
							.left{
								height: 100rpx;
								align-items: center;
								display: flex;
								font-size: 30rpx;
								color: #3b3b3b;
							}
						}
					}
				}
				.input{
					flex: 1;
					font-size: 28rpx;
					color: #a5a5a5;
				}
				.right{
					width: 540rpx;
					color: #a5a5a5;
					font-size: 30rpx;
					display: flex;
					justify-content: space-between;
					height: 100rpx;
					align-items: center;
					.r_left{
						display: flex;
						height: 100rpx;
						align-items: center;
						.r_l_img{
							width: 28rpx;
							height: 40rpx;
							margin-right: 10rpx;
						}
					}
					.s_img{
						width: 20rpx;
						height: 30rpx;
					}
				}
			}
		}
		.qd_btn{
			margin: 200rpx auto 0;
			text-align: center;
			width: 670rpx;
			height: 90rpx;
			background: #102d57;
			color: #fff;
			line-height: 90rpx;
			font-size: 36rpx;
			border-radius: 45rpx;
		}
	}
</style>
